package Day08_16;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class Test_HashMap01 {
    public static void main(String[] args) {
        Student s1 = new Student("李明");
        Student s2 = new Student("张三");
        Student s3 = new Student("李明");
        Set<Student> students = new HashSet<>();
        students.add(s1);
        students.add(s2);
        students.add(s3);
        System.out.println( students.size() );
        System.out.println( s1.hashCode() );
        System.out.println(s3.hashCode() );
    }
}
class Student{
    private String name;

    public Student(String name) {
        this.name = name;
    }

    public Student() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
